<?php

namespace application\admin\controller;

class index extends base {

    public function index() {
        $this->display('index');
    }

    /**
     * 管理员公共桌面
     */
    public function public_home() {

        $this->assign('software_info', $this->software_information());
        $this->assign('system_info', $this->system_information());
        $this->display('public_home');
    }

    public function system_information() {
        $systeminfo['WEB服务器'] = $_SERVER['SERVER_SOFTWARE'];
        $systeminfo['PHP版本'] = PHP_VERSION;
        $systeminfo['MySQL版本'] = db('')->version();
        $systeminfo['TICKY程序版本'] = TICKY_VERSION;
        $systeminfo['服务器操作系统'] = php_uname('s');
        $systeminfo['REGISTER_GLOBALS'] = ini_get('register_globals') ? '<span style="color:red;">ON</span>' : 'OFF';
        $systeminfo['MAGIC_QUOTES_GPC'] = MAGIC_QUOTES_GPC ? '<span style="color:red;">ON</span>' : 'OFF';
        $systeminfo['最大上传限制'] = ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'Disabled'; //最大上传限制
        $systeminfo['最大执行时间'] = ini_get('max_execution_time') . '秒'; //最大执行时间
        $systeminfo['服务器域名'] = $_SERVER['HTTP_HOST']; //服务器域名
        $systeminfo['服务器端口'] = $_SERVER['SERVER_PORT']; //服务器端口
        $systeminfo['脚本运行占用最大内存'] = get_cfg_var('memory_limit') ? get_cfg_var('memory_limit') : '---'; //脚本运行占用最大内存

        $html = '<table class="table table-condensed table-hover table-striped tablesorter table-fixed table-selectable">
		<thead>
			<tr>
				<th colspan="2" scope="col">系统信息</th>
			</tr>
		</thead>
		<tbody>';
        foreach ($systeminfo as $x => $x_value) {
            $html = $html . "<tr><td style='text-align: left;width: 300px;'>" . $x . "</td><td style='text-align: left;'>" . $x_value . "</td></tr>";
        }
        $html = $html . '</tbody></table>';
        return $html;
    }

    public function software_information() {
        $systeminfo['Ticky程序版本'] = TICKY_VERSION . ' &nbsp;[<a href="https://luomingui.cnblogs.com/" target="_blank">查看最新版本</a>]';
        $systeminfo['授权类型'] = '<span id=tkylicense">未授权（<a href="https://luomingui.cnblogs.com/" target="_blank" style="color:red">点击购买</a>）</span>';
        if (!is_file(RUNTIME_PATH . DS . 'install.lock')) {
            $systeminfo['安全提示'] = '程序安装锁（/runtime/install.lock）未存在！ <span class="c-red">可能会导致程序重装，请检查！</span>';
        }
        $systeminfo['系统开发'] = "罗敏贵";
        $systeminfo['官方网站'] = "luomingui.cnblogs.com";
        $html = '<table class="table table-condensed table-hover table-striped tablesorter table-fixed table-selectable">
		<thead>
			<tr>
				<th colspan="2" scope="col">软件信息</th>
			</tr>
		</thead>
		<tbody>';
        foreach ($systeminfo as $x => $x_value) {
            $html = $html . "<tr><td style='text-align: left;width: 300px;'>" . $x . "</td><td style='text-align: left;'>" . $x_value . "</td></tr>";
        }
        $html = $html . '</tbody></table>';
        return $html;
    }

}
